package com.brower.project.ui.viewmodel

import android.text.TextUtils
import com.brower.project.base.BaseViewModel

class LoginViewModel : BaseViewModel() {
    private var useName: String? = null
    private var psd: String? = null
    val usernameAfterChanged: (String) -> Unit = {
        useName = it
    }

    val psdAfterChanged: (String) -> Unit = {
        psd = it
    }
    fun login() {
        if (TextUtils.isEmpty(useName)) {
            showToast("用户名不能为空")
            return
        }
        if (TextUtils.isEmpty(psd)) {
            showToast("密码不能为空")
            return
        }
        showLoadView()
        launchFlow(
            request = { service.login(useName!!, psd!!) },
            resp = {},
            complete = {
                dismissLoadView()
            }
        )
    }
}